<?php

require_once ("include.php");
require_once ("registereduserobj.php");

function confirmaccount() {
 $id = @$_REQUEST['id'];
 if(ctype_alnum($id) && strlen($id) == 32) {
  $sql = "select * from registereduser where confirmcode = '$id' and isactive = 'N'";
  $ans = sqlreadarray($sql);
 } else {
  $ans = '';
 }
 if(sizeof($ans) == 0) {
  echo noaccount();
  exit;
 } else {
  setupaccount($ans,$id);
 }
}

function noaccount() {
 $o = "<h1>Either that link does not lead anywhere or your account is already active</h1>";
 return $o;
}

function setupaccount($registereduseritem,$id) {
 $sql = "update registereduser set isactive = 'Y', activateddate = SYSDATE(),confirmcode = 'ISCONFIRMCODE' where confirmcode = '$id'";
 sqlexec($sql);
}

?>

